package com.ryan.demo.jms.consumer.active.original;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.TextMessage;

import org.springframework.jms.core.JmsTemplate;

import com.ryan.demo.jms.consumer.ConsumerService;
  
public class OriginalConsumerServiceImpl implements ConsumerService {  
    JmsTemplate jmsTemplate;  
       
    Destination destination;  

    public void receiveMessage() {  
        TextMessage message = (TextMessage)jmsTemplate.receive();  
        try {  
            System.out.println(">>接收到的消息>>"+message.getText());  
        } catch (JMSException e) {  
            e.printStackTrace();  
        }  
    }  
    public void receiveMessageByCorrelationId(String correlationId){
        TextMessage message = (TextMessage)jmsTemplate.receiveSelected(correlationId);  
        try {  
            System.out.println(">>接收到的消息>>"+message.getText());  
        } catch (JMSException e) {  
            e.printStackTrace();  
        } 
    }
   
    public void setJmsTemplate(JmsTemplate jmsTemplate) {  
        this.jmsTemplate = jmsTemplate;  
    }  
   
    public void setDestination(Destination destination) {  
        this.destination = destination;  
    }  
}  